package controller;

import interfaces.IFHotelController;

import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
import java.util.List;

import model.Hotel;
import dao.DAOHotel;


@SuppressWarnings("serial")
public class HotelController extends UnicastRemoteObject implements IFHotelController {
	
	public HotelController() throws RemoteException {
		
	}
	
	public Hotel criarHotel(String nome, String gerente, Integer numeroDeQuartos) throws RemoteException {
		Hotel hotel = new Hotel();
		hotel.setNome(nome);
		hotel.setGerente(gerente);
		hotel.criarQuartos(numeroDeQuartos);
		
		DAOHotel daoHotel = new DAOHotel();
		daoHotel.persist(hotel);
		daoHotel.commit();
		
		return daoHotel.findLast();
		
	}
	
	public List<Hotel> getHoteis() throws RemoteException {
		DAOHotel daoHotel = new DAOHotel();
		return daoHotel.findAll();
		
	}
	
	

}
